package com.hua.yuan.ui;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageView;
import android.widget.TextView;

import com.hua.yuan.R;
import com.hua.yuan.common.BaseActivity;

/**
 * Created by huangyang on 2018/5/27.
 * 支付界面
 */

public class PlayActivity extends BaseActivity {

    private WebView webView;
    private ImageView backImage;
    private TextView titleView;

    private String url = "";

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_play);

        url = getIntent().getStringExtra("url");


        initView();
        initData();

    }

    private void initView() {

        webView = findViewById(R.id.webView);
        backImage = findViewById(R.id.backImage);
        titleView = findViewById(R.id.titleView);

    }

    private void initData() {
        initWebView();

        webView.loadUrl(url);

        backImage.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });

        titleView.setText("充值");


    }


    @SuppressLint("SetJavaScriptEnabled")
    private void initWebView() {
        WebSettings settings = webView.getSettings();
        settings.setJavaScriptEnabled(true);
        settings.setJavaScriptCanOpenWindowsAutomatically(true);
        settings.setPluginState(WebSettings.PluginState.ON);
        settings.setAllowFileAccess(true);
        settings.setLoadWithOverviewMode(true);
        settings.setUseWideViewPort(true);
        webView.setWebChromeClient(new WebChromeClient() {

        });
        webView.setWebViewClient(new WebViewClient() {


//            public boolean shouldOverrideUrlLoading(WebView view, String url) {
//                view.loadUrl(url);
//                return true;
//            }
//
//            @Override
//            public void onPageFinished(WebView view, String url) {
//
//
//                super.onPageFinished(view, url);
//            }


        });
    }
}
